GBML manual / Core

profile_budget

How many CPU cycles one frame has: 280,896. Spend more than that in one frame and the game runs slow.

Works differently on Game Boy - The Game Boy has no frame profiler: profile_enabled says false and every profile number reads 0.

Works differently on Game Boy Color - The Game Boy Color has no frame profiler: profile_enabled says false and every profile number reads 0.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

profile_budget() -> int

Returns

int

Description

How many CPU cycles one frame has: 280,896. That is 228 lines of the screen, with 1,232 cycles to each line. A game that spends more than this in one frame is late, and runs slow.

It is the same number whether or not the profiler is on. It is here so you can turn profile_cycles into a percentage yourself, or show how much room is left.

Example

var left = profile_budget() - profile_cycles(PROFILE_TOTAL);
draw_text(4, 4, $"CYCLES LEFT {left}");

Draws how many cycles were left over at the end of the last frame. If it goes below zero, the frame ran late.

On the GBA

The same number whether or not the profiler is on. It is 228 screen lines of 1,232 cycles each.

See also: profile_cyclesprofile_percent